﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufLabel.h"
#include "GnufQtItem.h"
#include "GnufAppearanceSetting.h"

#include <QLabel>

namespace gnuf {
    class QtLabel final : public QtItemWith<QLabel, Label, QWidget*>
    {
        Q_OBJECT
    public:
        QtLabel(Label* pLabel, QWidget* parent = nullptr);
        virtual ~QtLabel() ;

    public:
        void setText(const std::wstring& text);

        void setFixedWidthToWrapText(int tolerance);
        const std::wstring elideText(const std::wstring& origin, int elidedMaxiWidth);
        virtual void refresh(EWhatDirty) override;

        void onTableRowSelectionChanged(bool bSelected);

    protected:
        virtual void resizeEvent(QResizeEvent*);
        virtual void enterEvent(QEvent*) override;
        virtual void leaveEvent(QEvent*) override;
        void mousePressEvent(QMouseEvent* qEvent);

    private:
        void setStyle();
    private:
        bool m_isElided = false;
    };
}
